class Solution1:
    def modifyString(self, s: str) -> str:
        tmp = list(s)
        for i in range(0,len(tmp)):
            if tmp[i] == '?':
                for ch in range(ord('a'),ord('z')+1):
                    j = chr(ch)
                    if (i==0 or tmp[i-1]!=j) and (i==len(tmp)-1 or tmp[i+1]!=j):
                        tmp[i] = j
                        break
        return ''.join(tmp)

class Solution2:
    def findPoisonedDuration(self, timeSeries: list[int], duration: int) -> int:
        ret = 0
        for i in range(0,len(timeSeries)):
            if i == len(timeSeries)-1 or timeSeries[i]+duration <= timeSeries[i+1]:
                ret += duration
            else:
                ret += timeSeries[i+1]-timeSeries[i]
        return ret

class Solution3:
    def convert(self, s: str, numRows: int) -> str:
        if numRows == 1:
            return s
        ret = []
        d = 2*numRows-2
        for n in range(0,numRows): # 枚举Z型变换的每一行
            if n == 0 or n == numRows-1: # 第一行和最后一行性质相同
                i = n
                while i<len(s):
                    ret.append(s[i])
                    i += d
            else: # 中间行
                x1, x2 = n, d-n
                while x1<len(s) and x2<len(s):
                    ret.append(s[x1])
                    ret.append(s[x2])
                    x1 += d
                    x2 += d
                if x1 < len(s):
                    ret.append(s[x1])
        return ''.join(ret)

class Solution4:
    def countAndSay(self, n: int) -> str:
        ret = "1"
        for i in range(1,n):
            tmp = ""
            left,right = 0,0
            while right < len(ret):
                while right < len(ret) and ret[left] == ret[right]:
                    right+=1
                tmp += str(right-left)
                tmp += ret[left]
                left = right
            ret = tmp
        return ret

    class Solution5:
        def minNumberOfFrogs(self, croakOfFrogs: str) -> int:
            temp = "croak"
            n = len(temp)
            hash = [0] * n  # 0~4 分别映射c r o a k

            index = {}  # 记录对应字符在哈希表中下标
            for i in range(0, n):
                index[temp[i]] = i

            for e in croakOfFrogs:
                if e == 'c':
                    if hash[n - 1] != 0:
                        hash[n - 1] -= 1
                    hash[0] += 1
                else:
                    i = index[e]
                    if hash[i - 1]:
                        hash[i - 1] -= 1
                        hash[i] += 1
                    else:
                        return -1

            for i in range(0, n - 1):
                if hash[i] != 0:
                    return -1

            return hash[n - 1]

class Solution6:
    def deleteDuplicates(self, head: Optional[ListNode]) -> Optional[ListNode]:
        if head == None:
            return head

        cur = head
        while cur.next:
            if cur.val == cur.next.val:
                cur.next = cur.next.next
            else:
                cur = cur.next
        return head


class Solution7:
    def sortColors(self, nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
        i, left, right = 0, -1, len(nums)
        while i < right:
            if nums[i] == 0:
                nums[left + 1], nums[i] = nums[i], nums[left + 1]
                left += 1
                i += 1
            elif nums[i] == 1:
                i += 1
            else:
                nums[right - 1], nums[i] = nums[i], nums[right - 1]
                right -= 1


class Solution8:
    def sortArray(self, nums: list[int]) -> list[int]:
        random.seed(time.time())  # 初始化随机数种子
        self.qsort(nums, 0, len(nums) - 1)
        return nums

    def qsort(self, nums: list[int], l: int, r: int) -> None:
        if l >= r:
            return

        key = self.getRandomKey(nums, l, r)
        i, left, right = l, l - 1, r + 1
        while i < right:
            if nums[i] < key:
                nums[i], nums[left + 1] = nums[left + 1], nums[i]
                i += 1
                left += 1
            elif nums[i] == key:
                i += 1
            else:
                nums[i], nums[right - 1] = nums[right - 1], nums[i]
                right -= 1

        # 递归排序左右两部分
        self.qsort(nums, l, left)
        self.qsort(nums, right, r)

    def getRandomKey(self, nums: list[int], left: int, right: int) -> int:
        r = random.randint(left, right)
        return nums[r]


class Solution9:
    def getRandomPivot(self, nums: List[int], l: int, r: int) -> int:
        return nums[random.randint(l, r)]

    def quick_select(self, nums: List[int], l: int, r: int, k: int) -> int:
        if l == r:
            return nums[l]

        pivot = self.getRandomPivot(nums, l, r)  # 生成随机基准值
        left, right, i = l - 1, r + 1, l  # 获取需要进行partition的区间[l,r]
        while i < right:
            if nums[i] < pivot:
                nums[left + 1], nums[i] = nums[i], nums[left + 1]
                left += 1
                i += 1
            elif nums[i] == pivot:
                i += 1
            else:
                nums[right - 1], nums[i] = nums[i], nums[right - 1]
                right -= 1

        # [l,left] [left+1,right-1] [right,r]
        # 进行分类讨论，判断第k大落在那个区间
        b, c = right - left - 1, r - right + 1
        if c >= k:
            return self.quick_select(nums, right, r, k)
        elif b + c >= k:
            return pivot
        else:
            return self.quick_select(nums, l, left, k - b - c)

    def findKthLargest(self, nums: List[int], k: int) -> int:
        return self.quick_select(nums, 0, len(nums) - 1, k)


class Solution10:
    def getRandomPivot(self, nums: List[int], l: int, r: int) -> int:
        return nums[random.randint(l, r)]

    def partition(self, nums: List[int], l: int, r: int, pivot: int) -> int:
        left, right, i = l - 1, r + 1, l
        while i < right:
            if nums[i] < pivot:
                nums[left + 1], nums[i] = nums[i], nums[left + 1]
                left += 1
                i += 1
            elif nums[i] == pivot:
                i += 1
            else:
                nums[right - 1], nums[i] = nums[i], nums[right - 1]
                right -= 1
        return left, right

    def quick_select(self, nums: List[int], l: int, r: int, cnt: int) -> None:
        if r - l + 1 == cnt:
            return
        pivot = self.getRandomPivot(nums, l, r)
        left, right = self.partition(nums, l, r, pivot)

        a, b = left - l + 1, right - left - 1
        if a > cnt:
            return self.quick_select(nums, l, left, cnt)
        elif a + b >= cnt:
            return
        else:
            return self.quick_select(nums, right, r, cnt - a - b)

    def inventoryManagement(self, stock: List[int], cnt: int) -> List[int]:
        self.quick_select(stock, 0, len(stock) - 1, cnt)
        return stock[:cnt]

class Solution11:
    def __init__(self):
        self.tmp = None  # 初始化 tmp 为 None，将在 sortArray 中分配内存

    def merge(self, nums: list[int], l: int, mid: int, r: int) -> None:
        # [l,mid] [mid+1,r]
        i, j, k = l, mid+1, 0
        while i <= mid and j <= r:
            if nums[i] < nums[j]:
                self.tmp[k] = nums[i]
                i += 1
            else:
                self.tmp[k] = nums[j]
                j += 1
            k += 1

        while i<=mid:
            self.tmp[k] = nums[i]
            k += 1
            i += 1
        while j<=r:
            self.tmp[k] =nums[j]
            k += 1
            j += 1

        for p in range(l,r+1):
            nums[p] = self.tmp[p-l]

    def merge_sort(self, nums: list[int], l: int, r: int) -> None:
        if l>=r:
            return

        mid = (r-l)//2+l
        self.merge_sort(nums, l, mid)
        self.merge_sort(nums, mid+1, r)

        self.merge(nums, l, mid, r)


    def sortArray(self, nums: list[int]) -> list[int]:
        self.tmp = [None] * len(nums)  # 初始化 tmp 数组为与 nums 相同的大小
        self.merge_sort(nums, 0, len(nums)-1)
        return nums

class Solution12:
    def __init__(self):
        self.tmp = None  # 初始化 tmp 为 None，将在 sortArray 中分配内存

    def mergeInGreater(self, nums: list[int], l: int, mid: int, r: int) -> int:
        ret = 0
        # [l,mid] [mid+1,r]
        i, j, k = l, mid+1, 0
        while i <= mid and j <= r:
            if nums[i] <= nums[j]:
                self.tmp[k] = nums[i]
                i += 1
            else:
                ret += mid - i + 1
                self.tmp[k] = nums[j]
                j += 1
            k += 1

        while i<=mid:
            self.tmp[k] = nums[i]
            k += 1
            i += 1
        while j<=r:
            self.tmp[k] =nums[j]
            k += 1
            j += 1

        for p in range(l,r+1):
            nums[p] = self.tmp[p-l]

        return ret

    def mergeInLess(self, nums: list[int], l: int, mid: int, r: int) -> int:
        ret = 0
        # [l,mid] [mid+1,r]
        i, j, k = l, mid+1, 0
        while i <= mid and j <= r:
            if nums[i] <= nums[j]:
                self.tmp[k] = nums[j]
                j += 1
            else:
                ret += r - j + 1
                self.tmp[k] = nums[i]
                i += 1
            k += 1

        while i<=mid:
            self.tmp[k] = nums[i]
            k += 1
            i += 1
        while j<=r:
            self.tmp[k] =nums[j]
            k += 1
            j += 1

        for p in range(l,r+1):
            nums[p] = self.tmp[p-l]

        return ret

    def merge_sort(self, nums: list[int], l: int, r: int) -> int:
        if l>=r:
            return 0

        mid = (r - l) // 2 + l
        return self.merge_sort(nums, l, mid) + self.merge_sort(nums, mid+1, r) + self.mergeInLess(nums, l, mid, r)

    def reversePairs(self, record: List[int]) -> int:
        self.tmp = [None] * len(record)  # 初始化 tmp 数组为与 nums 相同的大小
        return self.merge_sort(record, 0, len(record)-1)


class Solution13:
    def __init__(self):
        self.tmp1 = []  # 临时存储nums
        self.tmp2 = []  # 临时存储index
        self.index = []  # 数组元素是nums对应元素的下标
        self.ret = []  # 存储结果

    # 降序，在后面找有多少个比我小
    def merge_in_less(self, nums, l, mid, r):
        # 合并有序数组
        # index数组也要合并，保证nums与index的对应关系
        i, j, k = l, mid + 1, 0
        while i <= mid and j <= r:
            if nums[i] <= nums[j]:
                self.tmp1[k] = nums[j]
                self.tmp2[k] = self.index[j]
                j += 1
            else:
                self.ret[self.index[i]] += r - j + 1
                self.tmp1[k] = nums[i]
                self.tmp2[k] = self.index[i]
                i += 1
            k += 1

        while i <= mid:
            self.tmp1[k] = nums[i]
            self.tmp2[k] = self.index[i]
            i += 1
            k += 1

        while j <= r:
            self.tmp1[k] = nums[j]
            self.tmp2[k] = self.index[j]
            j += 1
            k += 1

        # 覆盖原数组和index数组
        for p in range(l, r + 1):
            nums[p] = self.tmp1[p - l]
            self.index[p] = self.tmp2[p - l]

    def merge_sort(self, nums, l, r):
        if l >= r:
            return

        mid = (r - l) // 2 + l
        # [l, mid] [mid+1, r]
        self.merge_sort(nums, l, mid)
        self.merge_sort(nums, mid + 1, r)

        self.merge_in_less(nums, l, mid, r)

    def countSmaller(self, nums: List[int]) -> List[int]:
        if len(nums) == 1:
            return [0]

        self.tmp1 = [0] * len(nums)
        self.tmp2 = [0] * len(nums)
        self.ret = [0] * len(nums)
        self.index = [0] * len(nums)
        for i in range(0, len(nums)):
            self.index[i] = i

        self.merge_sort(nums, 0, len(nums) - 1)
        return self.ret

class Solution14:
    def __init__(self):
        self.tmp = []

    def merge_in_less(self, nums, left, mid, right):
        # 借助tmp排序区间
        i, j, k = left, mid + 1, 0
        while i <= mid and j <= right:  # 降序
            if nums[i] <= nums[j]:
                self.tmp[k] = nums[j]
                j += 1
            else:  # nums[i] > nums[j]
                self.tmp[k] = nums[i]
                i += 1
            k += 1

        # 处理没有排序的区间
        while i <= mid:
            self.tmp[k] = nums[i]
            i += 1
            k += 1
        while j <= right:
            self.tmp[k] = nums[j]
            j += 1
            k += 1

        # 覆盖原数组，使原数组有序
        for i in range(left, right + 1):
            nums[i] = self.tmp[i - left]

    def get_reverse_pairs(self, nums, left, mid, right):
        ret = 0
        left_index, right_index = left, mid + 1
        while left_index <= mid:  # 降序
            while right_index <= right and nums[left_index] / 2.0 <= nums[right_index]:
                right_index += 1
            if right_index > right:
                break
            ret += right - right_index + 1
            left_index += 1
        return ret

    def merge_sort(self, nums, left, right):
        if left >= right:
            return 0
        ret = 0

        # 划分区间
        mid = (right - left) // 2 + left

        # 处理左区间
        ret += self.merge_sort(nums, left, mid)

        # 处理右区间
        ret += self.merge_sort(nums, mid + 1, right)

        # 获取翻转对
        ret += self.get_reverse_pairs(nums, left, mid, right)

        # 合并有序数组
        self.merge_in_less(nums, left, mid, right)

        return ret

    def reversePairs(self, nums: List[int]) -> int:
        self.tmp = [0] * len(nums)  # 初始化tmp大小
        return self.merge_sort(nums, 0, len(nums) - 1)


from PIL import Image, ImageFont, ImageDraw

# 打开图片
img = Image.open(r"C:\Users\夏思成\Documents\她们\yangyumeng.png")

# 展示图片
# img.show()

# 获取字体
font = ImageFont.truetype(r"C:\Windows\Fonts\simsun.ttc", size = 30)

# 将打开的图片作为临时画布
draw = ImageDraw.Draw(img)

# 添加水印
draw.text(xy=(0,0), text = "@yangyumeng", fill = "white", font = font)

#展示添加水印后的图片
# img.show()

# 保存图片
img.save(r"D:\学习资料\杨煜萌.png")


# npodovoyiieedcad
# 自动发送qq邮件

import smtplib
from email.mime.multipart import MIMEMultipart
from email.header import Header
from email.mime.text import MIMEText
from email.mime.image import MIMEImage

# 连接qq邮箱
qqMail = smtplib.SMTP_SSL("smtp.qq.com", 465)

user = "3330826680@qq.com"
password = "npodovoyiieedcad"

# 登录qq邮箱
qqMail.login(user,password)


sender = "3330826680@qq.com"
receiver = "xscyj123@qq.com"

message = MIMEMultipart()
message["Subject"] = Header("团队合照")
message["From"] = Header(f"3330826680<{sender}>")
message["To"] = Header(f"xscyj123<{receiver}>")

textContent = "这是杨煜萌的照片"
mailContent = MIMEText(textContent, "plain", "utf-8")

filePath = r"C:\Users\夏思成\Documents\她们\yangyumeng.png"
with open(filePath, "rb") as imageFile:
    fileContent = imageFile.read()

attachment = MIMEImage(fileContent)
attachment.add_header("Content-Disposition", "attachment", filename="杨煜萌.png")

message.attach(mailContent)
message.attach(attachment)

qqMail.sendmail(sender, receiver, message.as_string())
print("发送成功")

import random


def phoneNo(operator, chooseType):
    # 前三位
    first_digit = 1
    second_digit = random.choice([3, 5, 7, 8, 9])

    if second_digit in [3, 8]:
        third_digit = random.choice(range(10))
    elif second_digit == 5:
        third_digit = random.choice([0, 1, 2, 3, 6, 7, 8, 9])
    elif second_digit == 7:
        third_digit = random.choice([0, 1, 2, 3, 5, 6, 8, 9])
    elif second_digit == 9:
        third_digit = random.choice([8, 9])

    # 第四位
    if operator == "四川移洞":
        fourth_digit = random.choice([5, 7, 8, 9])
    elif operator == "四川连通":
        fourth_digit = random.choice([0, 2, 5, 6, 9])
    elif operator == "四川电兴":
        fourth_digit = random.choice([3, 7, 9])
    else:
        return "没有该种营运商类型"

    # 后七位
    if chooseType == "选取靓号":
        last_seven_digits = random.choice([6666666, 8888888, 9999999])
    elif chooseType == "普通选号":
        last_seven_digits = random.randint(1000000, 9999999)
    else:
        return "没有该种选号类型"

    # 拼接手机号
    phone_number = f"{first_digit}{second_digit}{third_digit}{fourth_digit}{last_seven_digits}"
    return phone_number


# 调用函数
phoneNumber = phoneNo("四川连通", "选取靓号")

# 判断结果
if phoneNumber == "19999999999":
    print("我要办理该手机号，号码为：19999999999")
else:
    print("该号码不是我想要的号码，我不办理")